{extend name="public:layout" /}

{block name="title"}
    <title>{:site('siteName')}-代理列表</title>
{/block}

{block name="css"}
    <style>
        .layui-form-label{width:60px;    padding: 9px 6px;}
        .layui-input-block{margin-left:75px;margin-right:10px;}
        .layui-form-item { margin-bottom: 9px;}
        .layui-input::-webkit-input-placeholder{ color: #999;font-size:12px;}
        .layui-input::-moz-placeholder{  color: #999;font-size:12px; }
        .layui-input:-ms-input-placeholder{color: #999;font-size:12px;}
        .layui-tab-title li{width:50%;}
        .layui-tab-content {padding:0;}
        .layui-table td, .layui-table th{padding:5px 2px;}
        .layui-btn{    height: 25px;line-height: 25px;    padding: 0 3px;}
        .sell-tab { height: 40px; border-bottom: 1px solid #e2e2e2 }
        .sell-tab li { width: 50%; float: left; text-align: center; line-height: 40px; }
        .sell-tab .this { color: #009688; border-bottom: 3px solid #5FB878; margin-bottom: -3px;}
    </style>
{/block}

{block name="content"}
    <ul class="sell-tab">
        <li class="this">代理列表</li>
        <li>
            <a href="{:url('index/agent/record')}">充值记录</a>
        </li>
    </ul>
    <div class="layui-tab-content">
        <form action="{:url('index/agent/index')}" class="layui-form" data-type="sync" method="post">
            <div class="layui-form-item">
                <div class="layui-input-inline" style="margin: 10px 0 10px 7px;">
                    <input class="layui-input" lay-verify="required" name="field" placeholder="请输入用户名、姓名、手机号、QQ、微信搜索" type="text" value="{$field|default=''}" style="width:80%;float:left;">
                    </input>
                    <button lay-submit="" class="layui-btn layui-btn-primary layui-btn-small" style="height: 36px; width: 40px; margin-left: 10px;"><i class="layui-icon">&#xe615;</i> </button>
                </div>
            </div>
        </form>
        <div class="account_li">
            <ul>
                {volist name="agents" id="v"}
                    <li style="height: 188px;">
                        <p><span>用户名</span><br />{$v.username}</p>
                        <p><span>姓名</span><br />{$v.realname}</p>
                        <p><span>手机号</span><br />{$v.mobile}</p>
                        <p><span>qq/微信</span> <br />{$v.qq}<br>{$v.wechat}</p>
                        <p><span>支付宝</span><br />{$v.alipay}</p>
                        <p><span>银行</span><br />{$v.bank}-{$v.bank_card}</p>
                        <p><span>操作</span><br /><button class="layui-btn layui-btn-mini layui-btn-main confirm-recharge" data-uid="{$v['id']}">充值</button></p>
                    </li>
                {/volist}
            </ul>
        </div>
        <div class="page">
            {$agents->render()}
        </div>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        layui.use(['form', 'layer'], function(){
            var $ = layui.jquery;
            var layer = layui.layer;

            $(".confirm-recharge").click(function() {
                var uid = $(this).data('uid');
                checkPwd(function(pwd){
                    layer.prompt({
                        title: '请输入充值金额，1元=1{$currency}',
                    }, function(num, index, elem){
                        if(!/^\+?[1-9][0-9]*$/.test(num)){
                            layer.msg('请输入一个正整数');
                            return;
                        }
                        $.post('{:url("index/user/recharge")}', {uid: uid,num:num,pwd:pwd}, function(res) {
                            if(res.status == 1){
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function() {
                                    if(res.url){
                                        location.href = res.url;
                                    }else{
                                        location.reload();
                                    }
                                });
                            }else{
                                layer.msg(res.msg);
                            }
                        },'json');
                        layer.close(index);
                    });
                });
                return false;
            });
   
        });
    </script>
{/block}
